<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module ObjectSpace - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-count_objects">::count_objects</a>
    <li ><a href="#method-c-define_finalizer">::define_finalizer</a>
    <li ><a href="#method-c-each_object">::each_object</a>
    <li ><a href="#method-c-garbage_collect">::garbage_collect</a>
    <li ><a href="#method-c-undefine_finalizer">::undefine_finalizer</a>
    <li ><a href="#method-i-garbage_collect">#garbage_collect</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-ObjectSpace">
    <h1 id="module-ObjectSpace" class="module">
      module ObjectSpace
    </h1>

    <section class="description">
    
<p>The <a href="ObjectSpace.html"><code>ObjectSpace</code></a> module contains a number of routines that interact with the garbage collection facility and allow you to traverse all living objects with an iterator.</p>

<p><a href="ObjectSpace.html"><code>ObjectSpace</code></a> also provides support for object finalizers, procs that will be called when a specific object is about to be destroyed by garbage collection. See the documentation for <code>ObjectSpace.define_finalizer</code> for important information on how to use this method correctly.</p>

<pre class="ruby"><span class="ruby-identifier">a</span> = <span class="ruby-string">&quot;A&quot;</span>
<span class="ruby-identifier">b</span> = <span class="ruby-string">&quot;B&quot;</span>

<span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Finalizer one on #{id}&quot;</span> })
<span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-identifier">b</span>, <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Finalizer two on #{id}&quot;</span> })

<span class="ruby-identifier">a</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-identifier">b</span> = <span class="ruby-keyword">nil</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Finalizer</span> <span class="ruby-identifier">two</span> <span class="ruby-identifier">on</span> <span class="ruby-value">537763470</span>
<span class="ruby-constant">Finalizer</span> <span class="ruby-identifier">one</span> <span class="ruby-identifier">on</span> <span class="ruby-value">537763480</span>
</pre>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-count_objects" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          count_objects([result_hash]) &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Counts all objects grouped by type.</p>

<p>It returns a hash, such as:</p>

<pre class="ruby">{
  <span class="ruby-value">:TOTAL</span><span class="ruby-operator">=&gt;</span><span class="ruby-value">10000</span>,
  <span class="ruby-value">:FREE</span><span class="ruby-operator">=&gt;</span><span class="ruby-value">3011</span>,
  <span class="ruby-value">:T_OBJECT</span><span class="ruby-operator">=&gt;</span><span class="ruby-value">6</span>,
  <span class="ruby-value">:T_CLASS</span><span class="ruby-operator">=&gt;</span><span class="ruby-value">404</span>,
  <span class="ruby-comment"># ...</span>
}
</pre>

<p>The contents of the returned hash are implementation specific. It may be changed in future.</p>

<p>The keys starting with <code>:T_</code> means live objects. For example, <code>:T_ARRAY</code> is the number of arrays. <code>:FREE</code> means object slots which is not used now. <code>:TOTAL</code> means sum of above.</p>

<p>If the optional argument <code>result_hash</code> is given, it is overwritten and returned. This is intended to avoid probe effect.</p>

<pre class="ruby"><span class="ruby-identifier">h</span> = {}
<span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">count_objects</span>(<span class="ruby-identifier">h</span>)
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">h</span>
<span class="ruby-comment"># =&gt; { :TOTAL=&gt;10000, :T_CLASS=&gt;158280, :T_MODULE=&gt;20672, :T_STRING=&gt;527249 }</span>
</pre>

<p>This method is only expected to work on C Ruby.</p>

                              <div class="method-source-code" id="count_objects-source">
            <pre>static VALUE
count_objects(int argc, VALUE *argv, VALUE os)
{
    rb_objspace_t *objspace = &amp;rb_objspace;
    size_t counts[T_MASK+1];
    size_t freed = 0;
    size_t total = 0;
    size_t i;
    VALUE hash = Qnil;

    if (rb_check_arity(argc, 0, 1) == 1) {
        hash = argv[0];
        if (!RB_TYPE_P(hash, T_HASH))
            rb_raise(rb_eTypeError, &quot;non-hash given&quot;);
    }

    for (i = 0; i &lt;= T_MASK; i++) {
        counts[i] = 0;
    }

    for (i = 0; i &lt; heap_allocated_pages; i++) {
        struct heap_page *page = heap_pages_sorted[i];
        short stride = page-&gt;slot_size;

        uintptr_t p = (uintptr_t)page-&gt;start;
        uintptr_t pend = p + page-&gt;total_slots * stride;
        for (;p &lt; pend; p += stride) {
            VALUE vp = (VALUE)p;
            GC_ASSERT((NUM_IN_PAGE(vp) * BASE_SLOT_SIZE) % page-&gt;slot_size == 0);

            void *poisoned = asan_unpoison_object_temporary(vp);
            if (RANY(p)-&gt;as.basic.flags) {
                counts[BUILTIN_TYPE(vp)]++;
            }
            else {
                freed++;
            }
            if (poisoned) {
                GC_ASSERT(BUILTIN_TYPE(vp) == T_NONE);
                asan_poison_object(vp);
            }
        }
        total += page-&gt;total_slots;
    }

    if (NIL_P(hash)) {
        hash = rb_hash_new();
    }
    else if (!RHASH_EMPTY_P(hash)) {
        rb_hash_stlike_foreach(hash, set_zero, hash);
    }
    rb_hash_aset(hash, ID2SYM(rb_intern(&quot;TOTAL&quot;)), SIZET2NUM(total));
    rb_hash_aset(hash, ID2SYM(rb_intern(&quot;FREE&quot;)), SIZET2NUM(freed));

    for (i = 0; i &lt;= T_MASK; i++) {
        VALUE type = type_sym(i);
        if (counts[i])
            rb_hash_aset(hash, type, SIZET2NUM(counts[i]));
    }

    return hash;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-define_finalizer" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          define_finalizer(obj, aProc=proc())
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds <em>aProc</em> as a finalizer, to be called after <em>obj</em> was destroyed. The object ID of the <em>obj</em> will be passed as an argument to <em>aProc</em>. If <em>aProc</em> is a lambda or method, make sure it can be called with a single argument.</p>

<p>The return value is an array <code>[0, aProc]</code>.</p>

<p>The two recommended patterns are to either create the finaliser proc in a non-instance method where it can safely capture the needed state, or to use a custom callable object that stores the needed state explicitly as instance variables.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Foo</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">data_needed_for_finalization</span>)
    <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-keyword">self</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">create_finalizer</span>(<span class="ruby-identifier">data_needed_for_finalization</span>))
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">create_finalizer</span>(<span class="ruby-identifier">data_needed_for_finalization</span>)
    <span class="ruby-identifier">proc</span> {
      <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;finalizing #{data_needed_for_finalization}&quot;</span>
    }
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">Bar</span>
 <span class="ruby-keyword">class</span> <span class="ruby-constant">Remover</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">data_needed_for_finalization</span>)
      <span class="ruby-ivar">@data_needed_for_finalization</span> = <span class="ruby-identifier">data_needed_for_finalization</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">call</span>(<span class="ruby-identifier">id</span>)
      <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;finalizing #{@data_needed_for_finalization}&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">data_needed_for_finalization</span>)
    <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-keyword">self</span>, <span class="ruby-constant">Remover</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">data_needed_for_finalization</span>))
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>Note that if your finalizer references the object to be finalized it will never be run on <a href="GC.html"><code>GC</code></a>, although it will still be run at exit. You will get a warning if you capture the object to be finalized as the receiver of the finalizer.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">CapturesSelf</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">name</span>)
    <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">proc</span> {
      <span class="ruby-comment"># this finalizer will only be run on exit</span>
      <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;finalizing #{name}&quot;</span>
    })
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p>Also note that finalization can be unpredictable and is never guaranteed to be run except on exit.</p>

                              <div class="method-source-code" id="define_finalizer-source">
            <pre>static VALUE
define_final(int argc, VALUE *argv, VALUE os)
{
    VALUE obj, block;

    rb_scan_args(argc, argv, &quot;11&quot;, &amp;obj, &amp;block);
    should_be_finalizable(obj);
    if (argc == 1) {
        block = rb_block_proc();
    }
    else {
        should_be_callable(block);
    }

    if (rb_callable_receiver(block) == obj) {
        rb_warn(&quot;finalizer references object to be finalized&quot;);
    }

    return rb_define_finalizer_no_check(obj, block);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-each_object" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_object([module]) {|obj| ... } &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_object([module])              &rarr; an_enumerator
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Calls the block once for each living, nonimmediate object in this Ruby process. If <em>module</em> is specified, calls the block for only those classes or modules that match (or are a subclass of) <em>module</em>. Returns the number of objects found. Immediate objects (<code>Fixnum</code>s, <code>Symbol</code>s <code>true</code>, <code>false</code>, and <code>nil</code>) are never returned. In the example below, each_object returns both the numbers we defined and several constants defined in the <a href="Math.html"><code>Math</code></a> module.</p>

<p>If no block is given, an enumerator is returned instead.</p>

<pre class="ruby"><span class="ruby-identifier">a</span> = <span class="ruby-value">102.7</span>
<span class="ruby-identifier">b</span> = <span class="ruby-value">95</span>       <span class="ruby-comment"># Won&#39;t be returned</span>
<span class="ruby-identifier">c</span> = <span class="ruby-value">12345678987654321</span>
<span class="ruby-identifier">count</span> = <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">each_object</span>(<span class="ruby-constant">Numeric</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span> <span class="ruby-identifier">x</span> }
<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Total count: #{count}&quot;</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-value">12345678987654321</span>
<span class="ruby-value">102.7</span>
<span class="ruby-value">2.71828182845905</span>
<span class="ruby-value">3.14159265358979</span>
<span class="ruby-value">2.22044604925031e-16</span>
<span class="ruby-value">1.7976931348623157e+308</span>
<span class="ruby-value">2.2250738585072e-308</span>
<span class="ruby-constant">Total</span> <span class="ruby-value">count:</span> <span class="ruby-value">7</span>
</pre>

                              <div class="method-source-code" id="each_object-source">
            <pre>static VALUE
os_each_obj(int argc, VALUE *argv, VALUE os)
{
    VALUE of;

    of = (!rb_check_arity(argc, 0, 1) ? 0 : argv[0]);
    RETURN_ENUMERATOR(os, 1, &amp;of);
    return os_obj_of(of);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-garbage_collect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">garbage_collect</span><span
                                class="method-args">(full_mark: true, immediate_mark: true, immediate_sweep: true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="garbage_collect-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 325</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">garbage_collect</span> <span class="ruby-value">full_mark:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">immediate_mark:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">immediate_sweep:</span> <span class="ruby-keyword">true</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_start_internal</span> <span class="ruby-identifier">full_mark</span>, <span class="ruby-identifier">immediate_mark</span>, <span class="ruby-identifier">immediate_sweep</span>, <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-undefine_finalizer" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          undefine_finalizer(obj)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes all finalizers for <em>obj</em>.</p>

                              <div class="method-source-code" id="undefine_finalizer-source">
            <pre>static VALUE
undefine_final(VALUE os, VALUE obj)
{
    return rb_undefine_finalizer(obj);
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-garbage_collect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">garbage_collect</span><span
                                class="method-args">(full_mark: true, immediate_mark: true, immediate_sweep: true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="garbage_collect-source">
            <pre><span class="ruby-comment"># File ruby_3_3_0_preview2/gc.rb, line 325</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">garbage_collect</span> <span class="ruby-value">full_mark:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">immediate_mark:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">immediate_sweep:</span> <span class="ruby-keyword">true</span>
  <span class="ruby-constant">Primitive</span>.<span class="ruby-identifier">gc_start_internal</span> <span class="ruby-identifier">full_mark</span>, <span class="ruby-identifier">immediate_mark</span>, <span class="ruby-identifier">immediate_sweep</span>, <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

